<template>
	<view class="m30">
		<view class="p30 radius50 bgFff" v-if="orgInfo">
			<view class="flex-au">
				<u-image :src="orgInfo.logo" shape="circle" width="100" height="100"></u-image>
			</view>
			<view class="textC c343 mt30 f28">{{orgInfo.name}}</view>
			<u-gap height="20"></u-gap>
			<view class="f28 c343">
				<view class="flex-jus mb20">
					<text>地址</text>
					<text>{{orgInfo.address}}</text>
				</view>
				<view class="">
					<view>介绍</view>
					<view class="mt10 radiusBox bgF7 p20">{{orgInfo.content}}</view>
				</view>
			</view>
		</view>
		<view class="f28 bold c343 mt20">用户列表 ( {{userCount}} ) </view>
		<view class="p30 radius20 bgFff mt30" v-if="userList.length > 0">
			<view class="flex-jus f28 c343 flex-start" :class="{'mb30':index !== userList.length - 1}"
				v-for="(item,index) in userList" :key="item.id">
				<u-image :src="api_host + item.userAvatar" shape="circle" width="60" height="60"
					@click="openUrl('/subpage/meethuangshi/userInfo?uid='+item.userId)"></u-image>
				<view class="ml20 flex-jus flex1">
					<view class="mr10" @click="openUrl('/subpage/meethuangshi/userInfo?uid='+item.userId)">
						<view class="flex">
							<text class="f28 bold mr20 c343">{{item.nickName}}</text>
							<image v-if="item.sex"
								:src="'https://hxs.dsjhs.com:553/prod-api/profile/yujian/' + item.sex +'.png'" mode=""
								style="width: 30rpx;height: 30rpx;"></image>
						</view>
						<u-gap height="5"></u-gap>
						<view class="flex f24 c343">
							<text v-if="item.year">{{item.year}}岁</text>
							<text v-if="item.height" class="ml10">{{item.height}}cm</text>
							<text v-if="item.weight" class="ml20">{{item.weight}}kg</text>
							<text v-if="item.edu" class="ml20">{{item.edu}}</text>
						</view>
						<u-gap height="5"></u-gap>
						<view class="flex">
							<view class="flex" v-if="item.idCert === 2">
								<image src="https://hxs.dsjhs.com:553/prod-api/profile/yujian/sm.png" mode=""
									style="width: 30rpx;height: 30rpx;"></image>
								<text class="f24 c666 ml10">实名</text>
							</view>
							<view class="flex ml20" v-if="item.jobCert === 2">
								<image src="https://hxs.dsjhs.com:553/prod-api/profile/yujian/gz.png" mode=""
									style="width: 30rpx;height: 30rpx;"></image>
								<text class="f24 c666 ml10">工作</text>
							</view>
						</view>
						<u-gap height="5"></u-gap>
						<view class="flex flex-wrap" v-if="item.userTags">
							<view v-for="(tag,i) in item.userTags.split(',')" :key="tag" class="mr10 mb10">
								<u-tag :text="tag" shape="circle" size="mini" borderColor="#f7f7f7" bgColor="#f7f7f7"
									color="#333"></u-tag>
							</view>
						</view>
					</view>
					<view>
						<view
							@click.stop="openUrl(`/subpage/meethuangshi/chat?id=${item.userId}&nickName=${item.nickName}&userAvatar=${item.userAvatar}`)">
							<u-button type="success" shape="circle" color="linear-gradient(130deg, #FFA5F5, #319EFF)"
								:customStyle="{'fontSize':'26rpx'}">私信沟通</u-button>
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-gap height="200" v-if="type == 'exam'"></u-gap>
		<view class="bottom-box" v-if="type == 'exam'">
			<view class="p20">
				<u--textarea class="width100" v-model="form.content" border="none" height="100"
					placeholder="请输入不通过理由"></u--textarea>
			</view>
			<view class="flex-jus m20">
				<view class="flex1 mr10">
					<u-button type="" shape="circle" color="linear-gradient(170deg, #FFA5F5, #319EFF)"
						:customStyle="{'height':'80rpx'}" @click="reviewActUserBtn(1)">审核通过</u-button>
				</view>
				<view class="flex1 ml10">
					<u-button type="" shape="circle" color="#34314F" :customStyle="{'height':'80rpx'}"
						@click="reviewActUserBtn(2)">审核不通过</u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getOrgByInviteCode,
		reviewActUser,
		getOrgUsers
	} from '@/common/api_meethuangshi.js'
	export default {
		name: '',
		data() {
			return {
				userCount: 0,
				userList: [],
				orgInfo: null,
				type: null,
				code: null,
				actId: null,
				form: {
					content: ''
				}
			}
		},
		onLoad(option) {
			this.type = option.type;
			this.code = option.code;
			this.actId = option.id;
			this.getOrgByInviteCode()
		},
		methods: {
			async getOrgByInviteCode() {
				uni.showLoading({
					mask: true
				})
				const res = await getOrgByInviteCode({
					code: this.code
				})
				if (res.code === 200) {
					this.orgInfo = res.data;
					this.getOrgUsers()
					uni.hideLoading()
				}
			},
			async getOrgUsers() {
				const res = await getOrgUsers({
					id: this.orgInfo.id
				})
				if (res.code === 200) {
					this.userList = res.data.userList;
					this.userCount = res.data.memberCount;
				}
			},
			async reviewActUserBtn(status) {
				uni.showLoading({
					mask: true
				})
				const res = await reviewActUser({
					status,
					id: this.actId,
					reviewContent: this.form.content
				})
				if (res.code == 200) {
					uni.hideLoading();
					uni.showToast({
						title: '审核成功',
						icon: 'none',
						success() {
							setTimeout(() => {
								uni.navigateBack()
							}, 500)
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F7F6FF;
	}

	.bottom-box {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		background-color: #fff;
		border-radius: 50rpx 50rpx 0 0;
	}
</style>